﻿using SAM.Framework.Repository.Connection;
using SAM.Framework.Repository.Repositories;
using SAM.Framework.RepositoryDapper.NET40;
using SQLinq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SAM.Framework.RepositoryTest.NET40
{
    public class Program
    {
        public static void Main()
        {
            System.Data.Common.DbConnection connection = new System.Data.SqlClient.SqlConnection("server=.;uid=sa;pwd=123abc..;database=test");
            connection.Open();
            BaseDbContext dbContext = new BaseDbContext(connection);
            IRepository<Models.User, int> repository = new DapperRepositoryBase<Models.User>(dbContext, "t_user");
            var count = repository.Count();
            Console.WriteLine("the count is:" + count);
            var first = repository.FirstOrDefault(4);
            Console.WriteLine("the first Id =4 is:", first);

            var countId3 = repository.Count(w => w.Id==3);
            Console.WriteLine("the Count of Id =3 is:", countId3);

            var linq = new SQLinq.Dynamic.DynamicSQLinq("t_user").Join("abcd", "t_user.Id = abcd.Id");
            var xd = linq.ToSQL();
            var sql = xd.ToQuery();
            var qq = xd.Parameters;

        }
    }
}
